//
//  FYEmotion.swift
//  dugeweibo
//
//  Created by pelesys on 16/8/10.
//  Copyright © 2016年 杜方宜. All rights reserved.
//

import UIKit

class FYEmotion: NSObject {
  // MARK:-定义属性
    var code : String? {//emoji的code
        didSet {
            guard let code = code else {
                return
            }
            //1.创建扫描器
            let scanner = Scanner(string: code)
            //2.调用方法 ,扫描出code的值
            var value : UInt32 = 0
            scanner.scanHexInt32(&value)
            //3.将value转成字符
            let c = Character(UnicodeScalar(value)!)
            //4.将字符转成字符串
            emojiCode = String(c)
            
        }
    }
    var png : String?{//普通表情对应的图片名称
        didSet{
            guard let png = png else{
                return
            }
            pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
        }
    }
    
    var chs  : String?//普通表情对应的文字
    // MARK:-数据处理
    var pngPath : String?
    var emojiCode : String?
    var isRemove : Bool = false
    var isEmpty : Bool = false
    
    // MARK:-定义构造函数
    init(dict : [String : String]) {
        super.init()
        setValuesForKeys(dict)
    }
    init(isEmpty : Bool) {
        self.isEmpty = isEmpty
    }
    init(isRemove : Bool) {
        self.isRemove = isRemove
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    override class func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    override func setNilValueForKey(_ key: String) {
        
    }
    override var description: String{
        return dictionaryWithValues(forKeys: ["emojiCode", "pngPath", "chs"]).description
    }
}
